package com.hns.can.report.service;

import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.constants.GlobalConst;
import com.hns.can.common.formula.FillCodeDscValue;
import com.hns.can.common.formula.FillParamsVo;
import com.hns.can.report.entity.CommCarArrivalLeavesInfoEntity;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.report.vo.InnocentStopVo;
import com.hns.can.report.vo.NoReasonToStopVo;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import com.hns.tool.pub.PubUtil;
/**
 * Created by Lan on 2016/8/10.
 */
@Service
public class NoReasonToStopService  extends CommonService {
    @Autowired
    private FillCodeDscValue codeDscValue;

    /**
     * 查询
     * @param vo
     * @return
     * @throws Exception
     */
    @Transactional
    @LeftOrgAnnotation()
    public Pagination searchNoReasonToStopPage(NoReasonToStopVo vo) throws Exception {
        Pagination page = this.myBatisPage("noReasonToStop.searChNoResonToStopCnt", "noReasonToStop.searChNoResonToStopList", vo, InnocentStopVo.class);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);
        map = new HashMap<String,String>();
        map = new HashMap<String,String>();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo3 = new FillParamsVo("organId", map);
        map = new HashMap<String,String>();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo4 = new FillParamsVo("drvId", map);
        codeDscValue.fillInfoValue(page.getData(), new String[]{GlobalConst.CACHE_KEY_BASE_LINE_INFO,GlobalConst.CACHE_KEY_BASE_DRV_INFO,GlobalConst.CACHE_KEY_BASE_ORGAN}, vo1, vo3,vo4);
        return page;
    }

    /**
     * 导出
     * @param vo
     * @return
     * @throws Exception
     */
    @Transactional
    @LeftOrgAnnotation()
    public List<CommCarArrivalLeavesInfoEntity> searchNoReasonToStopList(NoReasonToStopVo vo) throws Exception {
        List list = PubUtil.convertListMapToObject( this.sqlMapDao.selectList("noReasonToStop.searChNoResonToStopList", vo), InnocentStopVo.class);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);
        map = new HashMap<String,String>();
        map.put("licPltNo", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo2 = new FillParamsVo("carId", map);
        map = new HashMap<String,String>();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo3 = new FillParamsVo("organId", map);
        map = new HashMap<String,String>();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo4 = new FillParamsVo("drvId", map);
        codeDscValue.fillInfoValue(list, new String[]{GlobalConst.CACHE_KEY_BASE_CAR_INFO, GlobalConst.CACHE_KEY_BASE_LINE_INFO,GlobalConst.CACHE_KEY_BASE_DRV_INFO,GlobalConst.CACHE_KEY_BASE_ORGAN}, vo1, vo2, vo3,vo4);
        return list;
    }
}
